﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using DSDCiZharp.Models.Itinerarios;
using System.Globalization;

namespace DSDCiZharp.Controllers
{
    public class VentaController : Controller
    {
        //
        // GET: /Venta/

        public ActionResult Index()
        {
            return View();
        }


        //
        // GET: /Venta/Destino

        public ActionResult Destino()
        {
            var options = new List<SelectListItem>();

            options.Add(new SelectListItem { Value = "1", Text = "ABANCAY", Selected = true });
            options.Add(new SelectListItem { Value = "2", Text = "AREQUIPA" });
            options.Add(new SelectListItem { Value = "3", Text = "HUARAZ" });
            options.Add(new SelectListItem { Value = "3", Text = "CUZCO" });
            options.Add(new SelectListItem { Value = "3", Text = "PIURA" });


            ViewData["ddlDestino"] = options;
            ViewData["ddlOrigen"] = options;



            return View();
        }

        [HttpPost]
        public ActionResult Destino(FormCollection collection)
        {
            string destino = collection["ddlDestino"].ToString();
            string origen = collection["ddlOrigen"].ToString();
            string fecha = collection["hdfFecha"].ToString();

            var model = new ItinerariosModel();

            model.ListarItinerarios();

            return View("Salida", model.lstItinerario.Where(x => x.Id_Destino.ToString().Equals(destino)).Where(y => y.Id_Origen.ToString().Equals(origen))/*.Where(z => string.Format("{0:dd/mm/yy}", z.Salida).Equals(fecha))*/);

            //return View("Salida");
        }

        //
        // GET: /Venta/Salida

        public ActionResult Salida()
        {

            return View();
        }

        //
        // GET: /Venta/Asiento

        public ActionResult Asiento()
        {
            return View();
        }
        //
        // GET: /Venta/DatosPersonales

        public ActionResult DatosPersonales()
        {
            return View();
        }
        //
        // GET: /Venta/Details/5

        public ActionResult Details(int id)
        {
            return View();
        }

        //
        // GET: /Venta/Create

        public ActionResult Create()
        {
            return View();
        } 

        //
        // POST: /Venta/Create

        [HttpPost]
        public ActionResult Create(FormCollection collection)
        {
            try
            {
                // TODO: Add insert logic here

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
        
        //
        // GET: /Venta/Edit/5
 
        public ActionResult Edit(int id)
        {
            return View();
        }

        //
        // POST: /Venta/Edit/5

        [HttpPost]
        public ActionResult Edit(int id, FormCollection collection)
        {
            try
            {
                // TODO: Add update logic here
 
                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }

        //
        // GET: /Venta/Delete/5
 
        public ActionResult Delete(int id)
        {
            return View();
        }

        //
        // POST: /Venta/Delete/5

        [HttpPost]
        public ActionResult Delete(int id, FormCollection collection)
        {
            try
            {
                // TODO: Add delete logic here
 
                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
    }
}
